<?php

class Application_Form_CursoEtapa extends Zend_Form
{

    public function init()
    {
        $this->clearDecorators();
        $decorators = array(
            array('ViewHelper'),
            array('Errors'),
            array('Label',array(
                'class' => 'leftalign'
            )),
            array('HtmlTag',array('tag' => 'li'))
        );

        $this->setName('cursoEtapa');

        $id = new Zend_Form_Element_Hidden('id');
        $id->addFilter('Int');

        $status_id = new Zend_Form_Element_Select('status_id');
        $status_id->setLabel('Status');
        $status_id->setMultiOptions(array(null));
        $status = new Status();
        $rowSet = $status->fetchAll(null);
        foreach($rowSet as $current)
        {
            $status_id->addMultiOption($current->id,$current->status);
        }
        $status_id->setDecorators($decorators);

        $responsavel_id = new Zend_Form_Element_Select('responsavel_id');
        $responsavel_id->setLabel('Responsavel');
        $responsavel_id->setMultiOptions(array(null));
        $responsaveis = new Usuarios();
        $results = $responsaveis->fetchAll(null,'nome');
        foreach($results as $responsavel):
            $responsavel_id->addMultiOption($responsavel->id, $responsavel->nome);
        endforeach;
        $responsavel_id->addDecorators($decorators);

        $tarefa = new Zend_Form_Element_Text('tarefa');
        $tarefa->setLabel('Tarefa')
            ->setAttrib('size', 50)
            ->setRequired(true)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty');
        $tarefa->setDecorators($decorators);

        $data_inicio = new Zend_Form_Element_Text('data_inicio');
        $data_inicio->setLabel('Data de início')
            ->setAttrib('size', 50)
            ->setRequired(true)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty');
        $data_inicio->setDecorators($decorators);

        $data_conclusao = new Zend_Form_Element_Text('data_conclusao');
        $data_conclusao->setLabel('Data de conclusão')
            ->setAttrib('size', 50)
            ->setRequired(true)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty');
        $data_conclusao->setDecorators($decorators);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton');
        $submit->setDecorators(array(
            array('ViewHelper'),
            array('HtmlTag',
                array(
                'tag' => 'li',
                'class' => 'submit'))
        ));

        $this->setDecorators(array(
           'FormElements',
            array('HtmlTag',array('tag'=>'ul')),
            array(
                array(
                    'DivTag'=>'HtmlTag'
                ),
                array(
                    'tag'=>'div',
                    'class'=>'FormDiv'
                )
            ),
            'Form'
        ));

        $this->addElements(array(
            $id,
            $status_id,
            $responsavel_id,
            $data_inicio,
            $data_conclusao,
            $submit
            ));
    }


}

